home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: automatic charrs
- Date: 24 Feb 1996 18:24:03 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Feb24112403@qcd.lanl.gov>
- References: <4glp29$dsh@d2.tufts.edu>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: rdorich@emerald.tufts.edu's message of 24 Feb 1996 01:19:05 GMT
-
- In article <4glp29$dsh@d2.tufts.edu>
- rdorich@emerald.tufts.edu (Roberto Dorich) writes:
-
- RD: Hello,
- RD:
- RD: Could someone enlighten me, and tell me why the following program runs
- RD: just dandy using Sun's cc (3.0.1), but crashes using gcc (?) ?
- RD:
- RD: #include <stdio.h>
- RD: char *b() { return "Hello";}
- RD:
- RD: main() {
- RD: char *a=b();
- RD:
- RD: a[0]='X';
-
- Because you are rtying to modify a string literal. This leads to
- undefined behaviour, which is a big no-no.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-